<?php
	header("Content-Type: text/html; charset=utf-8");
	require_once(dirname(__FILE__) . '/' . 'SQLOperation.class.php');
	
	$db = new SQLOperation("localhost", "test");
	if ($db->connect()) {		
		$result = $db->query("hospitals", "*", '');
		if ($result) {
			$list = array();
			while (($row = mysql_fetch_array($result)) != NULL) {
				$list[] = array("name"=>$row['name'], "code"=>$row['code']);
			}
			
			$arr = array("code"=>0, "msg"=>"success", "list"=>$list);
			echo json_encode($arr);
		} else {
			$arr = array("code"=>100, "msg"=>mysql_error());
			echo json_encode($arr);
		}
	
		$db->close();
	} else {
		$arr = array("code"=>100, "msg"=>mysql_error());
		echo json_encode($arr);
	}
?>